
import {Component,OnInit} from '@angular/core';
import { HttpClient, HttpResponse } from '@angular/common/http';
import {SysConfig,DataTablesResponse} from '../System/SystemConfig';

@Component({
    selector: 'student-list',
    templateUrl:'student-list.component.html',
    styleUrls:["student-list.component.css"]
    })
export class StudentlistComponent{

    dtOptions: DataTables.Settings = {};
    data: any[];

    constructor(private http: HttpClient) {}

    ngOnInit(): void {
    const that = this;

    this.dtOptions = {
    pagingType: 'full_numbers',
    pageLength: 10,
    serverSide: true,
    processing: true,
    ajax: (dataTablesParameters: any, callback) => {
        that.http.post<DataTablesResponse>(SysConfig.apiRoot+'/Studentlist',dataTablesParameters,{})
            .subscribe(resp => {
                that.data = resp.data;
                callback({
                    recordsTotal: resp.recordsTotal,
                    recordsFiltered: resp.recordsFiltered,
                    data: []
                });
            });
        },
    columns: [
                {data:'Name'},
                {data:'Phone'},
                {data:'Birthday'},
                {data:'Address'},
                {data:'Email'},
    ]
    };
  }
}